package cn.dwy2002.binaryhandwritingserver.service.service;


import cn.dwy2002.binaryhandwritingserver.exception.ProjectNotFoundException;
import cn.dwy2002.binaryhandwritingserver.exception.RelationNotFoundException;
import cn.dwy2002.binaryhandwritingserver.exception.ServiceException;
import cn.dwy2002.binaryhandwritingserver.exception.TagNotFoundException;

import java.util.List;


/**
 * @author 杜伟毅
 * @version 1.0
 * @since 2025/05/28
 */
public interface ProjectTagService {
    /**
     * 添加项目-标签关联
     *
     * @param projectId 项目ID
     * @param tagId     标签ID
     * @throws ProjectNotFoundException 项目不存在时抛出
     * @throws TagNotFoundException     标签不存在时抛出
     */
    void addProjectTag(Long projectId, Long tagId)
            throws ProjectNotFoundException, TagNotFoundException;

    /**
     * 批量添加项目标签关联
     *
     * @param projectId 项目ID
     * @param tagIds    标签ID列表
     * @return 成功添加的数量
     * @throws ProjectNotFoundException 项目不存在时抛出
     * @throws TagNotFoundException     标签不存在时抛出
     */
    int batchAddProjectTags(Long projectId, List<Long> tagIds)
            throws ProjectNotFoundException, TagNotFoundException;

    /**
     * 移除项目-标签关联
     *
     * @param projectId 项目ID
     * @param tagId     标签ID
     * @throws RelationNotFoundException 关联不存在时抛出
     */
    void removeProjectTag(Long projectId, Long tagId)
            throws RelationNotFoundException;

    /**
     * 清空项目所有标签关联
     *
     * @param projectId 项目ID
     * @return 删除的记录数
     * @throws ProjectNotFoundException 项目不存在时抛出
     */
    int clearProjectTags(Long projectId)
            throws ProjectNotFoundException;

    /**
     * 获取项目关联的标签ID列表
     *
     * @param projectId 项目ID
     * @return 标签ID列表（无关联时返回空列表）
     * @throws ProjectNotFoundException 项目不存在时抛出
     */
    List<Long> getProjectTags(Long projectId)
            throws ProjectNotFoundException;

    /**
     * 检查项目是否关联指定标签
     *
     * @param projectId 项目ID
     * @param tagId     标签ID
     * @return 存在返回true，否则false
     * @throws ServiceException 查询失败时抛出
     */
    boolean hasTag(Long projectId, Long tagId) throws ServiceException;
}
